<template>
  <div class="status-item">
    <div class="circle-box">
      <!-- 圆形指示器 -->
      <div :class="['circle', activeClass]">
        <div class="inner" v-if="isActive"></div>
      </div>
      <!-- 文字描述 -->
      <span class="label">{{ label }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "StatusItem",
  props: {
    // 状态值
    statusValue: {
      required: true,
    },
    // 激活时的类名前缀
    activeClassPrefix: {
      type: String,
      required: true,
    },
    // 文字描述
    label: {
      type: String,
      default: "",
    },
  },
  computed: {
    // 判断状态是否激活
    isActive() {
      return this.statusValue === "1";
    },
    // 动态计算激活类名
    activeClass() {
      return this.isActive ? this.activeClassPrefix : "";
    },
  },
};
</script>

<style scoped lang="less">
.status-item {
  width: 80%;
  position: relative;
  display: flex;
  justify-content: center;
  border: 1px solid #d6e6f4;
  padding: 5px 0;
  border-radius: 6px;
}

.label {
  font-size: 12px;
  text-align: center;
  margin: 0 6px;
}
.no-wrap {
  white-space: nowrap;
}

.circle-box {
  display: flex;
  align-items: center;

  .circle {
    width: 10px;
    height: 10px;
    min-width: 8px;
    min-height: 8px;
    border: 1px solid #999;
    border-radius: 50%;
    // margin-left: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;

    .inner {
      width: 4px;
      height: 4px;
      border-radius: 50%;
      background: #fff;
    }
  }
}
.reverse-order {
  flex-direction: row-reverse;
  justify-content: flex-end;
}

.circle.active-circle-primary {
  background: #7367f0;
  border-color: #7367f0;
  // animation: blinkAnimation 1s infinite;
}

.circle.active-circle-red {
  background: #f78989;
  border-color: #f78989;
  // animation: blinkAnimation 1s infinite;
}

.circle.active-circle-yellow {
  background: #ebb562;
  border-color: #ebb562;
  // animation: blinkAnimationYellow 1s infinite;
}

.circle.active-circle-green {
  background: #67c23a;
  border-color: #67c23a;
  // animation: blinkAnimation 1s infinite;
}

@keyframes blinkAnimation {
  0%,
  100% {
    background-color: #f56c6c; /* 闪烁时的背景色 */
    border-color: #f56c6c; /* 可选：闪烁时的边框色 */
  }
  50% {
    background-color: transparent; /* 透明表示“熄灭”状态 */
    border-color: transparent; /* 如果需要，也可以让边框在闪烁时消失 */
  }
}
@keyframes blinkAnimationYellow {
  0%,
  100% {
    background-color: #ebb562;
    border-color: #ebb562;
  }
  50% {
    background-color: transparent;
    border-color: transparent;
  }
}
</style>